package com.ruoyi.web.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.domain.Upplier;
import com.ruoyi.web.service.IUpplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * <p>
 * 供货单位
 * </p>
 */
@RestController
@RequestMapping("/database/upplier")
public class UpplierController  extends BaseController {
    @Autowired
    private IUpplierService upplierService;

    /**
     * 查询【供货单位】列表
     */
    @PreAuthorize("@ss.hasPermi('database:upplier:list')")
    @GetMapping("/list")
    public TableDataInfo list(Upplier upplier)
    {
        startPage();
        List<Upplier> list = upplierService.selectUpplierList(upplier);
        return getDataTable(list);
    }

    /**
     * 新增【供货单位】
     */
    @PreAuthorize("@ss.hasPermi('database:upplier:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Upplier upplier)
    {
        return toAjax(upplierService.insertUpplier(upplier));
    }

    /**
     * 删除【供货单位】
     */
    @PreAuthorize("@ss.hasPermi('database:upplier:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{supplierids}")
    public AjaxResult remove(@PathVariable Long[] supplierids)
    {
        return toAjax(upplierService.deleteUpplierBySupplierids(supplierids));
    }}
